package com.yrcm.eduapp.activity.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yrcm.eduapp.R;
import com.yrcm.eduapp.entity.XitiBaoEntity;

public class LXBaoListAdapter extends BaseAdapter {
	private List<XitiBaoEntity> data;
	private Context mContext;
	private LayoutInflater inflater;
	private int selectItem = 0;

	public LXBaoListAdapter(Context context, List<XitiBaoEntity> list) {
		this.mContext = context;
		this.data = list;
		this.inflater = LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		// TODO Auto-generated method stub
		HolderView holder;
		if (view == null) {
			view = inflater.inflate(R.layout.qhlx_home_bao_item, null);
			holder = new HolderView();
			holder.nameTxt1 = (TextView) view.findViewById(R.id.txt_bao);

		} else {
			holder = (HolderView) view.getTag();
		}
		holder.nameTxt1.setText(data.get(position).getName());

		if (position == selectItem) {
			view.setBackgroundColor(mContext.getResources().getColor(
					R.color.xiti_bao_list_color));
			holder.nameTxt1.setTextColor(Color.BLACK);
		} else {
			view.setBackgroundResource(R.drawable.heise_bg);
			holder.nameTxt1.setTextColor(Color.WHITE);
		}

		view.setTag(holder);
		return view;
	}

	class HolderView {
		TextView nameTxt1;

	}

	public void setSelectItem(int selectItem) {
		this.selectItem = selectItem;
	}

}
